Skip to content

Comments

refactor: eliminate duplicate data, simplify dependencies, fix singleton issues#350

Merged
recca0120 merged 4 commits intomainfrom
refactor/use-children-replace
Feb 16, 2026
Merged

refactor: eliminate duplicate data, simplify dependencies, fix singleton issues#350
recca0120 merged 4 commits intomainfrom
refactor/use-children-replace

Conversation

@recca0120
Copy link
Owner

Summary

  • Merge testItems into TestDefinitionIndex — added URI-based grouping (set/deleteByUri/getDefinitionsByUri), removed redundant testItems Map from TestCollection
  • O(1) findFile() lookup — added fileIndex Map in BaseTestCollection, replacing O(N) linear scan
  • Simplify DebugSessionManager — inject WorkspaceFolder directly instead of TestCollection
  • Fix Observer singleton issues — extract TestRunnerObserverFactory to create fresh OutputChannelObserver/ErrorDialogObserver per test run, eliminating shared mutable state
  • Fix OutputFormatter singleton issue — create new CollisionPrinter per run instead of global singleton, preventing cross-folder output interleaving
  • Apply early return pattern in PHPUnitXML, AttributeParser, TestCommandRegistry

Test plan

  • All 616 unit tests pass (npx vitest run)
  • CI passes

…server singleton issues

- Merge testItems Map into TestDefinitionIndex with URI-based grouping (set/deleteByUri/getDefinitionsByUri)
- Add O(1) fileIndex lookup in BaseTestCollection.findFile()
- Simplify DebugSessionManager to inject WorkspaceFolder directly instead of TestCollection
- Extract TestRunnerObserverFactory to create fresh observer instances per test run,
  eliminating shared mutable state in singleton OutputChannelObserver
- Remove @Injectable() from OutputChannelObserver and ErrorDialogObserver (no longer DI-managed)
- Apply early return pattern in PHPUnitXML, AttributeParser, and TestCommandRegistry
OutputFormatter/CollisionPrinter held per-run mutable state (outputBuffer,
errors[]) as a parent container singleton. When two workspace folders ran
tests concurrently, their output would interleave and errors could be
attributed to the wrong folder or lost entirely.

- Remove @Injectable from OutputFormatter and CollisionPrinter
- Remove OutputFormatter binding from parent container
- Create new CollisionPrinter instance per test run in TestRunnerObserverFactory
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 96.73913% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.48%. Comparing base (b8ef209) to head (1d54e25).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/Commands/TestCommandRegistry.ts 66.66% 1 Missing ⚠️
src/PHPUnit/TestCollection/TestCollection.ts 91.66% 1 Missing ⚠️
src/PHPUnit/TestParser/AttributeParser.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #350      +/-   ##
==========================================
- Coverage   94.54%   94.48%   -0.06%     
==========================================
  Files          76       77       +1     
  Lines        2785     2813      +28     
  Branches      489      495       +6     
==========================================
+ Hits         2633     2658      +25     
- Misses        137      140       +3     
  Partials       15       15              
Flag Coverage Δ
unittests 94.48% <96.73%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@recca0120 recca0120 merged commit 9d7652d into main Feb 16, 2026
14 checks passed
@recca0120 recca0120 deleted the refactor/use-children-replace branch February 16, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant